@extends('admin.public.header')
<style>
    .service_pic_badge {
        display: inline-block;
        min-width: 10px;
        padding: 3px 4px;
        font-size: 11px;
        font-weight: bold;
        color: #fff;
        line-height: 1;
        vertical-align: middle;
        white-space: nowrap;
        text-align: center;
        background-color: #777777;
        border-radius: 10px;
        
    }
    .dial_pic_badge {
        display: inline-block;
        min-width: 10px;
        padding: 3px 4px;
        font-size: 11px;
        font-weight: bold;
        color: #fff;
        line-height: 1;
        vertical-align: middle;
        white-space: nowrap;
        text-align: center;
        background-color: #777777;
        border-radius: 10px;
        
    }
    .web_service_badge {
        display: inline-block;
        min-width: 10px;
        padding: 3px 4px;
        font-size: 11px;
        font-weight: bold;
        color: #fff;
        line-height: 1;
        vertical-align: middle;
        white-space: nowrap;
        text-align: center;
        background-color: #777777;
        border-radius: 10px;
        
    }
    .wxapp_pic_url_badge {
        display: inline-block;
        min-width: 10px;
        padding: 3px 4px;
        font-size: 11px;
        font-weight: bold;
        color: #fff;
        line-height: 1;
        vertical-align: middle;
        white-space: nowrap;
        text-align: center;
        background-color: #777777;
        border-radius: 10px;
        
    }
    
    .layuimini-upload-show .uploads-delete-tip{
        right: 2px;
        top:1px;
    }
    
    .bg-red {
        background-color: #e74c3c !important;
    }
</style>
@section('listcontent')

    <form class="layui-form">
    <div class="layui-form layuimini-form">
       
        <input type="hidden" name="id" value="{{$info->id ?? 0}}" />
        
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
            <legend>商城设置</legend>
        </fieldset>
        <div class="layui-form-item">
            <label class="layui-form-label required">商城名称</label>
            <div class="layui-input-block">
                <input type="text" name="mall_name" value="{{ $info->mall_name ?? '' }}" lay-verify="required" lay-reqtext="商城名称不能为空" placeholder="请输入商城名称" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系电话</label>
            <div class="layui-input-block">
                <input type="text" name="contact_tel" value="{{ $info->contact_tel ?? '' }}" placeholder="请输入联系电话" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">开启在线客服</label>
            <div class="layui-input-block">
                @foreach($MallSettingModel->getIsServiceArr() as $k=>$v)
                    <input type="radio" name="show_customer_service" value="{{$k}}" title="{{$v}}" @if($k == ($info->show_customer_service ?? 0))checked="" @elseif(!isset($info->show_customer_service) && $k==0)checked="" @endif>
                @endforeach
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">客服图标</label>
            <div class="layui-input-block">
                <input name="service_pic" value="{{ $info->service_pic ?? '' }}" class="layui-input layui-col-xs6" placeholder="请上传图标">
                <button style="display: inline-block;position: absolute;right: 0px;" type="button" class="layui-btn" id="service_pic"><i class="layui-icon"></i>上传图标</button>
            </div>
            <ul class="layui-input-block layuimini-upload-show" style="margin-top: 10px;">
                <li><a><img style="width: 50px;height:50px;object-fit: contain;" id="service_pic_image" src="{{ $info->service_pic_show ?? '' }}"></a><small class="uploads-delete-tip bg-red service_pic_badge" data-upload-sign="|">×</small></li>
            </ul>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">一键拨号</label>
            <div class="layui-input-block">
                @foreach($MallSettingModel->getDialArr() as $k=>$v)
                    <input type="radio" name="dial" value="{{$k}}" title="{{$v}}" @if($k == ($info->dial ?? 0))checked="" @elseif(!isset($info->dial) && $k==0)checked="" @endif>
                @endforeach
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">拨号图标</label>
            <div class="layui-input-block">
                <input name="dial_pic" value="{{ $info->dial_pic ?? '' }}" class="layui-input layui-col-xs6" placeholder="请上传图标">
                <button style="display: inline-block;position: absolute;right: 0px;" type="button" class="layui-btn" id="dial_pic"><i class="layui-icon"></i>上传图标</button>
            </div>
            <ul class="layui-input-block layuimini-upload-show" style="margin-top: 10px;">
                <li><a><img style="width: 50px;height:50px;object-fit: contain;" id="dial_pic_image" src="{{ $info->dial_pic_show ?? '' }}"></a><small class="uploads-delete-tip bg-red dial_pic_badge" data-upload-sign="|">×</small></li>
            </ul>
        </div>
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
            <legend>订单设置</legend>
        </fieldset>
        <div class="layui-form-item">
            <label class="layui-form-label">自动收货时间</label>
            <div class="layui-input-block" style="width:380px;">
                <input type="text" name="delivery_time" value="{{ $info->delivery_time ?? '10' }}" placeholder="请输入自动收货时间" class="layui-input" onKeyUp="this.value=this.value.replace(/[^\.\d]/g,'');this.value=this.value.replace('.','');" lay-verify="required" lay-reqtext="自动收货时间不能为空">
                <tip>订单发货后到期自动确认收货时间</tip>
                <button style="display: inline-block;position: absolute;right: 0px;margin-top: -38px;" type="button" class="layui-btn layui-btn-disabled">天</button>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">申请售后时间</label>
            <div class="layui-input-block" style="width:380px;">
                <input type="text" name="after_sale_time" value="{{ $info->after_sale_time ?? '7' }}" placeholder="请输入售后时间" class="layui-input" onKeyUp="this.value=this.value.replace(/[^\.\d]/g,'');this.value=this.value.replace('.','');" lay-verify="required" lay-reqtext="申请售后时间不能为空">
                <tip>订单发货后可进行售后申请的时间</tip>
                <button style="display: inline-block;position: absolute;right: 0px;margin-top: -38px;" type="button" class="layui-btn layui-btn-disabled">天</button>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">未支付订单取消</label>
            <div class="layui-input-block" style="width:380px;">
                <input type="text" name="over_day" value="{{ $info->over_day ?? '1' }}" placeholder="请输入订单取消时间" class="layui-input" onKeyUp="this.value=this.value.replace(/[^\.\d]/g,'');this.value=this.value.replace('.','');" lay-verify="required" lay-reqtext="未支付订单取消时间不能为空">
                <tip>未支付订单到期自动取消订单 为0则表示不开启！</tip>
                <button style="display: inline-block;position: absolute;right: 0px;margin-top: -38px;" type="button" class="layui-btn layui-btn-disabled">小时</button>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">快递鸟商户ID</label>
            <div class="layui-input-block">
                <input type="text" name="kdniao_mch_id" value="{{ $info->kdniao_mch_id ?? '' }}" placeholder="请输入快递鸟商户ID" class="layui-input">
                <tip>第三方物流 快递鸟商户号</tip>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">快递鸟API KEY</label>
            <div class="layui-input-block">
                <input type="text" name="kdniao_api_key" value="{{ $info->kdniao_api_key ?? '' }}" placeholder="请输入快递鸟API KEY" class="layui-input">
                <tip>第三方物流 快递鸟api key</tip>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">发货方式</label>
            <div class="layui-input-block">
                @foreach($MallSettingModel->getSendTypeArr() as $k=>$v)
                    <input type="radio" name="send_type" value="{{$k}}" title="{{$v}}" @if($k == ($info->send_type ?? 0))checked="" @elseif(!isset($info->send_type) && $k==0)checked="" @endif>
                @endforeach
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">支付方式</label>
            <div class="layui-input-block">
                <input type="checkbox" name="payment[wechat]" title="微信支付" @if(($info['payment']['wechat'] ?? '') == 'on')checked @endif>
                <input type="checkbox" name="payment[huodao]" title="货到付款" @if(($info['payment']['huodao'] ?? '') == 'on')checked @endif>
                <input type="checkbox" name="payment[balance]" title="余额支付" @if(($info['payment']['balance'] ?? '') == 'on')checked @endif>
            </div>
            <tip style="line-height: 35px;font-size: 10px;color: #a29c9c;">默认支持微信支付</tip>
        </div>
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
            <legend>页面设置</legend>
        </fieldset>
        <div class="layui-form-item">
            <label class="layui-form-label">分类页面样式</label>
            <div class="layui-input-block">
                @foreach($MallSettingModel->getCatStyleArr() as $k=>$v)
                    <input type="radio" name="cat_style" value="{{$k}}" title="{{$v}}" @if($k == ($info->cat_style ?? 1))checked="" @elseif(!isset($info->cat_style) && $k==0)checked="" @endif>
                @endforeach
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">分类页面分隔符</label>
            <div class="layui-input-block">
                @foreach($MallSettingModel->getCutThreadArr() as $k=>$v)
                    <input type="radio" name="cut_thread" value="{{$k}}" title="{{$v}}" @if($k == ($info->cut_thread ?? 0))checked="" @elseif(!isset($info->cut_thread) && $k==0)checked="" @endif>
                @endforeach
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">首页购买记录</label>
            <div class="layui-input-block">
                @foreach($MallSettingModel->getPurchaseFrameArr() as $k=>$v)
                    <input type="radio" name="purchase_frame" value="{{$k}}" title="{{$v}}" @if($k == ($info->purchase_frame ?? 0))checked="" @elseif(!isset($info->purchase_frame) && $k==0)checked="" @endif>
                @endforeach
            </div>
            <tip style="line-height: 35px;font-size: 10px;color: #a29c9c;">应用于首页用户购买记录展示</tip>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">推荐商品</label>
            <div class="layui-input-block">
                @foreach($MallSettingModel->getIsRecommendArr() as $k=>$v)
                    <input type="radio" name="is_recommend" value="{{$k}}" title="{{$v}}" @if($k == ($info->is_recommend ?? 0))checked="" @elseif(!isset($info->is_recommend) && $k==0)checked="" @endif>
                @endforeach
            </div>
            <tip style="line-height: 35px;font-size: 10px;color: #a29c9c;">应用于商品详情页</tip>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">推荐商品显示数量</label>
            <div class="layui-input-block" style="width:380px;">
                <input type="text" name="recommend_count" value="{{ $info->recommend_count ?? '16' }}" placeholder="请输入商品显示数量" class="layui-input" onKeyUp="this.value=this.value.replace(/[^\.\d]/g,'');this.value=this.value.replace('.','');" lay-verify="required" lay-reqtext="推荐商品显示数量不能为空">
                <tip>商品详情页 推荐商品显示的最大数量！</tip>
                <button style="display: inline-block;position: absolute;right: 0px;margin-top: -38px;" type="button" class="layui-btn layui-btn-disabled">个</button>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">首页分类商品（每行个数）</label>
            <div class="layui-input-block">
                <select name="cat_goods_cols">
                    <option value="1" @if(($info->cat_goods_cols ?? '') == 1) selected="" @endif>1</option>
                    <option value="2" @if(($info->cat_goods_cols ?? '') == 2) selected="" @endif>2</option>
                    <option value="3" @if(($info->cat_goods_cols ?? '') == 3) selected="" @endif>3</option>
                </select>     
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">首页分类商品（显示个数）</label>
            <div class="layui-input-block" style="width:380px;">
                <input type="text" name="cat_goods_count" value="{{ $info->cat_goods_count ?? '6' }}" placeholder="请输入分类商品（显示个数" class="layui-input" onKeyUp="this.value=this.value.replace(/[^\.\d]/g,'');this.value=this.value.replace('.','');" lay-verify="required" lay-reqtext="首页分类商品（显示个数）不能为空">
                <tip>每个分类板块显示的商品最大数量（0~100）</tip>
                <button style="display: inline-block;position: absolute;right: 0px;margin-top: -38px;" type="button" class="layui-btn layui-btn-disabled">个</button>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">开启领券中心</label>
            <div class="layui-input-block">
                @foreach($MallSettingModel->getIsCouponArr() as $k=>$v)
                    <input type="radio" name="is_coupon" value="{{$k}}" title="{{$v}}" @if($k == ($info->is_coupon ?? 0))checked="" @elseif(!isset($info->is_coupon) && $k==0)checked="" @endif>
                @endforeach
            </div>
            <tip style="line-height: 35px;font-size: 10px;color: #a29c9c;">是否开启领券中心页面</tip>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">首页导航栏（一行显示个数）</label>
            <div class="layui-input-block">
                @foreach($MallSettingModel->getNavCountArr() as $k=>$v)
                    <input type="radio" name="nav_count" value="{{$k}}" title="{{$v}}" @if($k == ($info->nav_count ?? 0))checked="" @elseif(!isset($info->nav_count) && $k==0)checked="" @endif>
                @endforeach
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">会员积分</label>
            <div class="layui-input-block" style="width:380px;">
                <input type="text" name="integral" value="{{ $info->integral ?? '1' }}" lay-verify="required" lay-reqtext="会员积分不能为空" class="layui-input" onKeyUp="this.value=this.value.replace(/[^\.\d]/g,'');this.value=this.value.replace('.','');">
                <tip>多少积分抵扣一元 为0则表示不抵扣！</tip>
                <button style="display: inline-block;position: absolute;right: 0px;margin-top: -38px;" type="button" class="layui-btn layui-btn-disabled">积分抵扣1元</button>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">商城首页公告</label>
            <div class="layui-input-block" style="width:380px;">
                <textarea name="notice_content" placeholder="请输入公告内容" class="layui-textarea">{{$info->notice_content ?? ''}}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">积分使用规则</label>
            <div class="layui-input-block" style="width:380px;">
                <textarea name="integration" placeholder="请输入会员积分使用规则" class="layui-textarea">{{$info->integration ?? ''}}</textarea>
            </div>
        </div>
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
            <legend>其他设置</legend>
        </fieldset>
        <div class="layui-form-item">
            <label class="layui-form-label">客服图标（跳转外链）</label>
            <div class="layui-input-block">
                <input name="web_service" value="{{ $info->web_service ?? '' }}" class="layui-input layui-col-xs6" placeholder="请上传图标">
                <button style="display: inline-block;position: absolute;right: 0px;" type="button" class="layui-btn" id="web_service"><i class="layui-icon"></i>上传图标</button>
            </div>
            <ul class="layui-input-block layuimini-upload-show" style="margin-top: 10px;">
                <li><a><img style="width: 50px;height:50px;object-fit: contain;" id="web_service_image" src="{{ $info->web_service_show ?? '' }}"></a><small class="uploads-delete-tip bg-red web_service_badge" data-upload-sign="|">×</small></li>
            </ul>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">客服外链地址</label>
            <div class="layui-input-block">
                <input type="text" name="web_service_url" value="{{ $info->web_service_url ?? '' }}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">悬浮图标（跳转小程序）</label>
            <div class="layui-input-block">
                <input name="wxapp_pic_url" value="{{ $info->wxapp_pic_url ?? '' }}" class="layui-input layui-col-xs6" placeholder="请上传图标">
                <button style="display: inline-block;position: absolute;right: 0px;" type="button" class="layui-btn" id="wxapp_pic_url"><i class="layui-icon"></i>上传图标</button>
            </div>
            <ul class="layui-input-block layuimini-upload-show" style="margin-top: 10px;">
                <li><a><img style="width: 50px;height:50px;object-fit: contain;" id="wxapp_pic_url_image" src="{{ $info->wxapp_pic_url_show ?? '' }}"></a><small class="uploads-delete-tip bg-red wxapp_pic_url_badge" data-upload-sign="|">×</small></li>
            </ul>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">跳转小程序APPID</label>
            <div class="layui-input-block" style="width:380px;">
                <input type="text" name="wxapp_appid" value="{{ $info->wxapp_appid ?? '' }}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">跳转小程序路径</label>
            <div class="layui-input-block">
                <input type="text" name="wxapp_path" value="{{ $info->wxapp_path ?? '' }}" class="layui-input">
            </div>
        </div>
        <div class="hr-line"></div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" id="saveBtn" lay-submit lay-filter="saveBtn">保存</button>
            </div>
        </div>

    </div>
    </form>
@endsection

@section('listscript')
    <script type="text/javascript">
        layui.use(['iconPickerFa', 'form', 'layer', 'upload', 'xmSelect'], function () {
            var iconPickerFa = layui.iconPickerFa,
                form = layui.form,
                layer = layui.layer,
                upload = layui.upload,
                xmSelect = layui.xmSelect,
                $ = layui.$;
            
            //上传客服图标
            var uploadInst = upload.render({
                elem: '#service_pic'
                ,url: '/admin/upload/upload' //改成您自己的上传接口
                ,accept: 'images' //图片
                ,acceptMime:'image/*'
                ,headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }
                ,before: function(obj){
                    //预读本地文件示例，不支持ie8
                    obj.preview(function(index, file, result){
                        $('#service_pic_image').attr('src', result); //图片链接（base64）
                    });
                }
                ,done: function(res){
                    //如果上传失败
                    if(res.code > 0){
                        return layer.msg('上传失败',{icon: 2});
                    }
                    //上传成功
                    $("input[name=service_pic]").val(res.data);
                    return layer.msg('上传成功',{icon: 1});
                }
                ,error: function(){
                    //演示失败状态
                    return layer.msg('上传失败',{icon: 2});
                }
            });
            
            //上传拨号图标
            var uploadInst = upload.render({
                elem: '#dial_pic'
                ,url: '/admin/upload/upload' //改成您自己的上传接口
                ,accept: 'images' //图片
                ,acceptMime:'image/*'
                ,headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }
                ,before: function(obj){
                    //预读本地文件示例，不支持ie8
                    obj.preview(function(index, file, result){
                        $('#dial_pic_image').attr('src', result); //图片链接（base64）
                    });
                }
                ,done: function(res){
                    //如果上传失败
                    if(res.code > 0){
                        return layer.msg('上传失败',{icon: 2});
                    }
                    //上传成功
                    $("input[name=dial_pic]").val(res.data);
                    return layer.msg('上传成功',{icon: 1});
                }
                ,error: function(){
                    //演示失败状态
                    return layer.msg('上传失败',{icon: 2});
                }
            });

            //上传客服图标（跳转外链）
            var uploadInst = upload.render({
                elem: '#web_service'
                ,url: '/admin/upload/upload' //改成您自己的上传接口
                ,accept: 'images' //图片
                ,acceptMime:'image/*'
                ,headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }
                ,before: function(obj){
                    //预读本地文件示例，不支持ie8
                    obj.preview(function(index, file, result){
                        $('#web_service_image').attr('src', result); //图片链接（base64）
                    });
                }
                ,done: function(res){
                    //如果上传失败
                    if(res.code > 0){
                        return layer.msg('上传失败',{icon: 2});
                    }
                    //上传成功
                    $("input[name=web_service]").val(res.data);
                    return layer.msg('上传成功',{icon: 1});
                }
                ,error: function(){
                    //演示失败状态
                    return layer.msg('上传失败',{icon: 2});
                }
            });

            //上传悬浮图标（跳转小程序）
            var uploadInst = upload.render({
                elem: '#wxapp_pic_url'
                ,url: '/admin/upload/upload' //改成您自己的上传接口
                ,accept: 'images' //图片
                ,acceptMime:'image/*'
                ,headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }
                ,before: function(obj){
                    //预读本地文件示例，不支持ie8
                    obj.preview(function(index, file, result){
                        $('#wxapp_pic_url_image').attr('src', result); //图片链接（base64）
                    });
                }
                ,done: function(res){
                    //如果上传失败
                    if(res.code > 0){
                        return layer.msg('上传失败',{icon: 2});
                    }
                    //上传成功
                    $("input[name=wxapp_pic_url]").val(res.data);
                    return layer.msg('上传成功',{icon: 1});
                }
                ,error: function(){
                    //演示失败状态
                    return layer.msg('上传失败',{icon: 2});
                }
            });

            // 删除客服图标
            $(document).on("click", ".service_pic_badge", function(event){
                layer.confirm('确认删除？', {
                    title : "操作确认",
                    skin: 'layui-layer-lan',
                    btn: ['确认','取消'] //按钮
                }, function(){
                    $("#service_pic_image").attr('src','');
                    $("input[name=service_pic]").val('');
                    layer.msg("操作成功",{icon: 1});
                }, function(){
                    layer.msg('已取消', {icon: 1});
                });
                
            });

            // 删除拨号图标
            $(document).on("click", ".dial_pic_badge", function(event){
                layer.confirm('确认删除？', {
                    title : "操作确认",
                    skin: 'layui-layer-lan',
                    btn: ['确认','取消'] //按钮
                }, function(){
                    $("#dial_pic_image").attr('src','');
                    $("input[name=dial_pic]").val('');
                    layer.msg("操作成功",{icon: 1});
                }, function(){
                    layer.msg('已取消', {icon: 1});
                });
                
            });

            // 删除客服图标（跳转外链）
            $(document).on("click", ".web_service_badge", function(event){
                layer.confirm('确认删除？', {
                    title : "操作确认",
                    skin: 'layui-layer-lan',
                    btn: ['确认','取消'] //按钮
                }, function(){
                    $("#web_service_image").attr('src','');
                    $("input[name=web_service]").val('');
                    layer.msg("操作成功",{icon: 1});
                }, function(){
                    layer.msg('已取消', {icon: 1});
                });
                
            });

            // 删除悬浮图标（跳转小程序）
            $(document).on("click", ".wxapp_pic_url_badge", function(event){
                layer.confirm('确认删除？', {
                    title : "操作确认",
                    skin: 'layui-layer-lan',
                    btn: ['确认','取消'] //按钮
                }, function(){
                    $("#wxapp_pic_url_image").attr('src','');
                    $("input[name=wxapp_pic_url]").val('');
                    layer.msg("操作成功",{icon: 1});
                }, function(){
                    layer.msg('已取消', {icon: 1});
                });
                
            });

            //监听提交
            form.on('submit(saveBtn)', function(data){
                $("#saveBtn").addClass("layui-btn-disabled");
                $("#saveBtn").attr('disabled', 'disabled');
                var loading = layer.msg('加载中..', {icon: 16,shade: 0.3,time: false});
                $.ajax({
                    url:'/admin/mall_setting/setting',
                    type:'post',
                    data:data.field,
                    dataType:'JSON',
                    headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
                    success:function(res){
                        layer.close(loading);  //返回数据关闭loading
                        if(res.code==0){
                            layer.msg(res.message,{icon: 1},function (){
                                parent.location.reload();
                            });
                        }else{
                            layer.msg(res.message,{icon: 2});
                            $("#saveBtn").removeClass("layui-btn-disabled");
                            $("#saveBtn").removeAttr('disabled');
                        }
                    },
                    error:function (data) {
                        layer.msg(res.message,{icon: 2});
                        $("#saveBtn").removeClass("layui-btn-disabled");
                        $("#saveBtn").removeAttr('disabled');
                    }
                });
            });
        });
    </script>
@endsection